package com;

import java.io.File;
import java.io.FilenameFilter;

public class FileNameFilterExt implements FilenameFilter{
    public String allExt;
	public String javaExt;
    public String propsExt;
    public String htmlExt;
    public String txtExt;
    public String xmlExt;
    public FileNameFilterExt(String ext){
    	if(ext.equalsIgnoreCase("jar")){
    		allExt=ext;
    	}else{
	    	this.allExt =ext;
	    	System.out.println("FileNameFilterExt:FileNameFilterExt:"+this.allExt);
	    	String extArr[] = allExt.split(":");
	    	System.out.println("FileNameFilterExt:FileNameFilterExt:"+extArr);
	    	javaExt=extArr[0];
	    	txtExt=extArr[1];
	    	propsExt=extArr[2];
	    	htmlExt=extArr[3];
	    	xmlExt=extArr[4];
    	}
    }
	@Override
	public boolean accept(File dir, String name) {
		// TODO Auto-generated method stub
		if(allExt.equalsIgnoreCase("jar")){
			return name.endsWith("jar");
		}else{
			return name.endsWith(javaExt)||
				   name.endsWith(txtExt)||
				   name.endsWith(propsExt)||
				   name.endsWith(htmlExt)||
				   name.endsWith(xmlExt);
		}
	}

}
